<style lang="less" scoped>
	//修改插件样式
	.ivu-notice{
		width: 280px!important;
		height: 64px;
		background: #FFFFFF;
		box-shadow: 8px 0 8px 0 rgba(104,110,113,0.10);
		border-radius: 4px;	
	}
</style>
<style lang="less">
	//修改插件样式
	.ivu-notice{
		width: 280px!important;
		border-radius: 4px;	
		top:70px!important;
		.ivu-notice-notice{
			box-shadow: 8px 0 8px 0 rgba(104,110,113,0.10);			
			padding:10px 20px 2px;
			margin-bottom: 6px;
			border:1px solid #F0F1F1;
		}
		.ivu-notice-icon-success{
			display: none;
		}
		.ivu-notice-with-icon .ivu-notice-title{
			margin-left:0;
		}
		.ivu-notice-custom-content:after{
			display: none;
		}
		.noticeImg{
			width: 52px;
			height: 52px;
			vertical-align: middle;
			margin-right:12px;
		}
		a{
			color:#FFA14C;
		}
		.nums{
			color:#FB9132;
		}
	}

</style>
<template>
    <div class="noticeWrap">

    </div>
</template>
<script>
    import global from '../config/global';
	import { mapActions } from 'vuex';
    export default {
		data() {
				return {
				}
			},
        props: {
           
        },
        created(){
            this.messagePush();
        },
		methods:{
			messagePush(){
				//判断是否登录
				if(!window.localStorage["user"]){
					return;
				}
				var a = require('../images/news_xt@3x.png');
				var b = require('../images/news_hd@3x.png');
				var c = require('../images/news_zj@3x.png');
				if(JSON.parse(localStorage.getItem('user')).status == 1){					
					this.$http.post(global.host+'/message/push',{},{headers:{"Authorization":JSON.parse(localStorage.getItem('user')).token_type+" "+JSON.parse(localStorage.getItem('user')).access_token}})
					.then((response) => {	
						if(response.body.status == 1 && response.body.data.activity != 0 && localStorage.getItem("preactivity") < response.body.data.activity){							
							this.$Notice.close('activity');
							this.$Notice.success({
								title: "<img class='noticeImg' src="+b+" /><span class='nums'>"+response.body.data.activity+"</span> 条活动消息，<a href='usercenterMessage?type=2'/>点击查看</a>",
								duration:0,
								name:"activity",
							});
							localStorage.setItem("preactivity", response.body.data.activity);
						}
						if(response.body.status == 1 && response.body.data.memoir != 0 && localStorage.getItem("prememoir") < response.body.data.memoir){
							this.$Notice.close('memoir');							
							this.$Notice.success({
								title: "<img class='noticeImg' src="+c+" /><span class='nums'>"+response.body.data.memoir+"</span> 条传记消息，<a href='usercenterMessage?type=3'/>点击查看</a>",
								duration:0,
								name:"memoir",
							});
							localStorage.setItem("prememoir", response.body.data.memoir);							
						}
						if(response.body.status == 1 && response.body.data.system != 0 && localStorage.getItem("presystem") < response.body.data.system){
							this.$Notice.close('system');							
							this.$Notice.success({
								title: "<img class='noticeImg' src="+a+" /><span class='nums'>"+response.body.data.system+"</span> 条系统消息，<a href='usercenterMessage?type=1'/>点击查看</a>",
								duration:0,
								name:"system",
								
							});
							localStorage.setItem("presystem", response.body.data.system);							
						}							
					})

				}else{
					console.log('未登录状态');
				}
            },
		}
    }
</script>